// pages/mine/mine.js
const app = getApp()
const common = require('../../utils/util.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    default: '/image/default.png',
    default2: '/image/default2.png',
    info: {
      account_type: 1, //1普通 2跑腿
      avatarUrl: '',
    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onShow: function (options) {
    this.getInfo();
  },
  getInfo() {
    let that = this;
    common.getData_user(
      common.config.UserInfo, {},
      "post",
      function (res) {
        let userInfo = wx.getStorageSync("userInfo");
        let userInfoNew = res.user_info || {}
        userInfoNew = {
          ...userInfo,
          ...userInfoNew
        }
        wx.setStorageSync('userInfo', userInfoNew)
        that.setData({
          info: userInfoNew
        });
      }
    );
  },
  golink: function (e) {
    let {
      type,
      url
    } = e.currentTarget.dataset;
    if (type == 'tab' && url=='/pages/news/newsList') {
      // 资讯
      app.globalData.isMine = true;
      console.log(app.globalData.isMine)
      wx.switchTab({
        url,
      })
    } else {
      wx.navigateTo({
        url: e.currentTarget.dataset.url,
      });
    }
  },
  makeCall() {
    // todo 号码
    wx.makePhoneCall({
      phoneNumber: '182',
      success: () => {
        analysis.eventdata(that, that.data.mdTel);
      },
      fail: () => {}
    });
  }
})